package logic

import (
	"context"
	"goodsrpc/goods"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type MyReleaseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMyReleaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MyReleaseLogic {
	return &MyReleaseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MyReleaseLogic) MyRelease(req *types.MyReleaseRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	release, err := l.svcCtx.Goods.MyRelease(l.ctx, &goods.MyReleaseRequest{UserId: req.UserId})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msy:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msy:  "我的展示成功",
		Data: release,
	}, nil
}
